import { ColumnProps, PaginationConfig } from "antd/lib/table";
import * as React from "react";
import { IColumn } from "../../interfaces";
import { defaultState } from "../../store/reducer";
import Action_add from "../action/add";
import Action_edit from "../action/edit";
import { formatTimeStamp10 } from "../../../../../common/tools/time_utils";

// 获取分页信息
export function getPaginationInfo(total: number): PaginationConfig {
  return {
    total,
    defaultCurrent: defaultState.table_filter.pageNum,
    defaultPageSize: defaultState.table_filter.pageSize,
    showSizeChanger: true, //是否可以改变pageSize
    showQuickJumper: true, //跳转
    showTotal: (total: number, _: any) => `共${total}条`,
    pageSizeOptions: ["10", "20", "50"], //每页条数选项,
    position: "bottom"
  };
}

export function columnsFun() {
  const columns: ColumnProps<IColumn>[] = [
    {
      title: (
        <React.Fragment>
          <Action_add />
        </React.Fragment>
      ),
      key: "action",
      render: (_: any, record: IColumn) => (
        <span>
          <Action_edit record={record} />
        </span>
      )
    },
    {
      title: "ID",
      dataIndex: "id",
      key: "id",
      sorter:true
    },
    {
      title: "名称",
      dataIndex: "name",
      key: "name"
    },
  ];
  return columns;
}
